import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import axios from 'axios'
import {
  Tabbar,
  TabbarItem,
  Col,
  Row,
  Toast,
  Swipe,
  SwipeItem,
  Search,
  Lazyload,
  TreeSelect,
  Icon,
  List,
  Cell,
  ImagePreview,
  GoodsAction,
  GoodsActionButton,
  GoodsActionIcon,
  Empty,
  AddressList,
  AddressEdit,
  Button,
  Card,
  Checkbox,
  CheckboxGroup,
  SwipeCell,
  SubmitBar,
  Dialog,
  NavBar,
  Area,
  Grid,
  GridItem,
  Form,
  Field,
} from 'vant'
import 'vant/lib/index.less';

Vue.config.productionTip = false
Vue.prototype.$http = axios
axios.defaults.baseURL = 'http://127.0.0.1:9090'


// 挂载vant插件
Vue.use(Tabbar)
Vue.use(TabbarItem)
Vue.use(Col)
Vue.use(Row)
Vue.use(Toast)
Vue.use(Swipe)
Vue.use(SwipeItem)
Vue.use(Search)
Vue.use(Lazyload)
Vue.use(TreeSelect)
Vue.use(Icon)
Vue.use(List)
Vue.use(Cell)
Vue.use(ImagePreview)
Vue.use(GoodsAction)
Vue.use(GoodsActionButton)
Vue.use(GoodsActionIcon)
Vue.use(Empty)
Vue.use(AddressEdit)
Vue.use(AddressList)
Vue.use(Button)
Vue.use(Card)
Vue.use(Checkbox)
Vue.use(CheckboxGroup)
Vue.use(SwipeCell)
Vue.use(SubmitBar)
Vue.use(Dialog)
Vue.use(NavBar)
Vue.use(Area)
Vue.use(Grid)
Vue.use(GridItem)
Vue.use(Form)
Vue.use(Field)

// 请求拦截器
axios.interceptors.request.use(function (config) {
  Toast.loading({
    message: '数据加载中...',
    forbidClick: true
  })
  return config
},
  function (err) {
    return Promise.reject(err)
  }
)
// 响应拦截器
axios.interceptors.response.use(function (config) {
  Toast('数据加载完成')
  return config
},
  function (err) {
    return Promise.reject(err)
  }
)




new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
